<?php

namespace addons\CustomerService\backend\controllers;

use Yii;
use common\helpers\DateHelper;
use common\helpers\ResultHelper;

/**
 * 运营中心
 *
 * Class ConsoleController
 * @package addons\CustomerService\backend\controllers
 */
class ConsoleController extends BaseController
{
    /**
     * 首页
     *
     * @return string
     * @throws \yii\web\NotFoundHttpException
     */
    public function actionIndex()
    {
        return $this->render($this->action->id,[]);
    }

    /**
     * 咨询次数
     */
    public function actionHistoryCount($type = '')
    {
        if (Yii::$app->request->isAjax) {
            $data = Yii::$app->customerServiceService->robot->getBetweenCountStatToEchant($type);

            return ResultHelper::json(200, '获取成功', $data);
        }

        return $this->render($this->action->id, [
            'total' => Yii::$app->customerServiceService->robot->getStatByTime(0),
        ]);
    }
}